package middleware

import (
	"organoid_public/pkg/response"
)

type MiddlewareTrees struct {
	Mid map[string]BaseMid
}

func NewMiddlewareTrees(middles []string, response *response.GinRestResponse) *MiddlewareTrees {
	mid := &MiddlewareTrees{}

	if len(middles) <= 0 {
		return mid
	}
	for _, m := range middles {
		switch m {
		case "checkoutAuth":
			mid.Mid[m] = NewLoginAuthMiddleware(response)
			break
		case "discernApp":
			mid.Mid[m] = NewDiscernAppMiddleware(response)
		}
	}
	return mid
}

func (m *MiddlewareTrees) Get(key string) (BaseMid, bool) {
	val, exits := m.Mid[key]
	return val, exits
}
